﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="OrderManagement.aspx.cs" Inherits="Hosting.OrderManagement" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="asp" %>

<%@ Register TagPrefix="oajax" Namespace="OboutInc" Assembly="obout_AJAXPage" %> 

<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="obout" %>

<%@ Register Assembly="obout_Window_NET" Namespace="OboutInc.Window" TagPrefix="owd" %>

<%@ Register Assembly="obout_SuperForm" Namespace="Obout.SuperForm" TagPrefix="obout" %>

<%@ Register Assembly="obout_Grid_NET" TagPrefix="obout" Namespace="Obout.Grid" %>

<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.HTMLEditor" TagPrefix="obout" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<a href="#" id="anchorGridNotification"></a>
<div class="notification attention png_bg" id="divGridValidation" style="display:none;">
	<div id="divGridNotification" runat="server">
        <label id="GridNotificationLabel">Update status of control.</label>
	</div>
</div>

<input type="hidden" runat="server" id="txtOId" />

<asp:UpdatePanel ID="udp1" runat="server">
<ContentTemplate>
<div style="position: relative; z-index: 0;">

<%--Order--%>
<obout:Grid id="gOrder" runat="server" AutoGenerateColumns="False" CallbackMode="false" Serialize="false"
    DataSourceID="ldsOrder" AllowFiltering="true" EnableTypeValidation="true"
    AllowColumnResizing="false"
    AllowRecordSelection="false"
    OnInsertCommand="gOrder_InsertCommand"
    OnUpdateCommand="gOrder_UpdateCommand"
    OnDeleteCommand="gOrder_DeleteCommand" PageSizeOptions="5,10,20,50" AllowManualPaging="True" AllowMultiRecordSelection="False">

<ScrollingSettings ScrollWidth="900px" />
<ClientSideEvents ExposeSender="true" OnBeforeClientDelete="gOrder_BeforeClientDelete" 
    OnBeforeClientUpdate="gOrder_BeforeClientUpdate" OnBeforeClientInsert="gOrder_BeforeClientInsert" />

<Columns>
    <obout:Column DataField="OId" HeaderText="ID" Visible="false" ReadOnly="true" Width="50px" />
    <obout:Column DataField="ODate" HeaderText="Date" ReadOnly="true" />
    <obout:Column DataField="ClientName" HeaderText="Name" />
    <obout:Column DataField="ClientEmail" HeaderText="Email" />
    <obout:Column DataField="ClientGender" HeaderText="Gender">
        <TemplateSettings EditTemplateId="tplGender" />
    </obout:Column>
    <obout:Column DataField="ClientPhone" HeaderText="Phone" />
    <obout:Column DataField="ClientAddress" HeaderText="Description" Width="380px">
        <TemplateSettings EditTemplateId="tplEditDescription" />
    </obout:Column>
    <obout:Column DataField="IsDone" HeaderText="Finish">
        <TemplateSettings EditTemplateID="tplEditActive" />
    </obout:Column>
    <obout:Column AllowEdit="true" AllowDelete="true" AllowSorting="false" />
</Columns>

<Templates>
    <obout:GridTemplate runat="server" ID="tplGender" ControlID="sGender">
        <Template>
            <obout:OboutDropDownList runat="server" ID="sGender">
                <asp:ListItem Value="male">Male</asp:ListItem>
                <asp:ListItem Value="female">Female</asp:ListItem>
            </obout:OboutDropDownList>
        </Template>
    </obout:GridTemplate>
    <obout:GridTemplate runat="server" ID="tplEditActive" ControlID="cbActive" ControlPropertyName="checked">
        <Template>
            <input type="checkbox" id="cbActive"/>
        </Template>
    </obout:GridTemplate>
    <obout:GridTemplate runat="server" ID="tplEditDescription" ControlID="cbDescription">
        <Template>
            <obout:OboutTextBox ID="cbDescription" Width="880px" runat="server" TextMode="MultiLine" Height="100px"></obout:OboutTextBox>
        </Template>
    </obout:GridTemplate>
</Templates>

<MasterDetailSettings LoadingMode="OnCallback" ShowEmptyDetails="true" />

<DetailGrids>

    <obout:DetailGrid id="dgOrderDetail" runat="server" AutoGenerateColumns="false" DataSourceID="ldsOrderDetails" AllowColumnResizing="false"
         AllowRecordSelection="false" AllowFiltering="true"  CallbackMode="false" Serialize="false"
         OnInsertCommand="dgOrderDetail_InsertCommand"
         OnUpdateCommand="dgOrderDetail_UpdateCommand"
         OnDeleteCommand="dgOrderDetail_DeleteCommand"
         PageSizeOptions="5,10,20,50" AllowManualPaging="True" AllowMultiRecordSelection="False" ForeignKeys="OId">

    <ScrollingSettings ScrollWidth="850px" />
    <ClientSideEvents ExposeSender="true" OnBeforeClientDelete="dgOrderDetail_BeforeClientDelete" OnBeforeClientInsert="dgOrderDetail_BeforeClientInsert" />

    <Columns>
    <obout:Column DataField="OId" HeaderText="Order ID" runat="server" ReadOnly="true" />
    <obout:Column DataField="ODId" HeaderText="Order Detail ID" runat="server" ReadOnly="true" />
    <obout:Column DataField="ServiceDetail" HeaderText="Package Detail" runat="server" />
    <obout:Column  AllowEdit="true" AllowDelete="true" AllowSorting="false" />
    </Columns>

</obout:DetailGrid>

</DetailGrids>

</obout:Grid>

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="udp1">
        <ProgressTemplate>
			<div class="loading-image">
				<img src="../img/loaderWhite.gif" alt="Not image">
			</div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    </div>
</ContentTemplate>
</asp:UpdatePanel>

<asp:LinqDataSource EnableInsert="true" EnableDelete="true" EnableUpdate="true" ID="ldsOrder"
    ContextTypeName="Hosting.Class.HostingDomainWebsiteDataContext"
    TableName="TBL_Orders" runat="server" />

<asp:LinqDataSource EnableInsert="true" EnableDelete="true" EnableUpdate="true" ID="ldsOrderDetails"
    ContextTypeName="Hosting.Class.HostingDomainWebsiteDataContext"
    TableName="TBL_OrderDetails" runat="server" Where="OId = @OId">
        <WhereParameters>
            <asp:Parameter Name="OId" DbType="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>

</asp:Content>

<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="js/MessageValid.js"></script>    <%--Show Message--%>
<script type="text/javascript">

    function gOrder_BeforeClientDelete() {
        if (confirm('Are you sure you want to delete this Order and children?') == false) {
            return false;
        }
        return true;
    }

    function dgOrderDetail_BeforeClientDelete() {
        if (confirm('Are you sure you want to delete this Order Detail?') == false) {
            return false;
        }
        return true;
    }
    </script>

<style type="text/css">
        .super-form
        {
            margin: 12px;
        }
        
        .ob_fC table td
        {
            white-space: normal !important;
        }
        
        .command-row .ob_fRwF
        {
            padding-left: 50px !important;
        }
        
        #<%= UpdateProgress1.ClientID %>
    {
        position: absolute;
        z-index: 50; 
        top: 0px; 
        bottom: 0px; 
        left: -5px; 
        right: 5px; 
        width: auto; 
        height: auto;
        background-color: #EEEEEE;
        text-align: center;
        filter: alpha(opacity=60);
        -moz-opacity: 0.6;
        opacity: 0.6;
    }
        
    .loading-image
    {
        position: absolute;
        font-family: Verdana;
	    font-size: 10px;
	    color:#0C416F;
	    height: 10px;
	    top: 50%;	
	    bottom: 0px;
	    margin-top: -5px;	
	    left: 0px;
	    right: 0px;
	    margin-left: auto;
	    margin-right: auto;
	    text-align: center;
	    width: 100%;
    }
    </style>

<script language="javascript" type="text/javascript" src="js/Order.js"></script>
<script language="javascript" type="text/javascript" src="js/GridMessageValid.js"></script>
<script language="javascript" type="text/javascript">

    function dgOrderDetail_BeforeClientInsert(sender, record) {
        document.getElementById("<%=txtOId.ClientID %>").value = sender.ForeignKeys.OId.Value;
    }

    function gOrder_BeforeClientUpdate(sender, record) {
        var isValid = OrderValid(record.ClientName, record.ClientEmail, record.ClientPhone, record.ClientAddress);
        if (isValid == 1) {
            return true;
        }
        else if (isValid == 10) {
            getMessageAttention("Customer name is null or empty");
        }
        else if (isValid == 20) {
            getMessageAttention("Customer email is not valid");
        }
        else if (isValid == 21) {
            getMessageAttention("Customer email is not valid");
        }
        else if (isValid == 30) {
            getMessageAttention("Customer phone is null or empty");
        }
        else if (isValid == 31) {
            getMessageAttention("Customer phone is not valid");
        }
        else if (isValid == 40) {
            getMessageAttention("Customer address is null or empty");
        }
        return false;
    }

    function gOrder_BeforeClientInsert(sender, record) {
        var isValid = OrderValid(record.ClientName, record.ClientEmail, record.ClientPhone, record.ClientAddress);
        if (isValid == 1) {
            return true;
        }
        else if (isValid == 10) {
            getMessageAttention("Customer name is null or empty");
        }
        else if (isValid == 20) {
            getMessageAttention("Customer email is not valid");
        }
        else if (isValid == 21) {
            getMessageAttention("Customer email is not valid");
        }
        else if (isValid == 30) {
            getMessageAttention("Customer phone is null or empty");
        }
        else if (isValid == 31) {
            getMessageAttention("Customer phone is not valid");
        }
        else if (isValid == 40) {
            getMessageAttention("Customer address is null or empty");
        }
        hideNotification(6000);
        return false;
    }

</script>

</asp:Content>


